/**
 * Created With IntelliJ IDEA
 * Description:牛客网：BM31 对称的二叉树
 * <a href="https://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb?tpId=295&tqId=23452&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj">...</a>
 * User: DELL
 * Data: 2022-11-28
 * Time: 22:48
 */

class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}

public class Solution {
    public boolean recursion (TreeNode lRoot,TreeNode rRoot) {
        if (lRoot == null && rRoot == null) {
            return true;
        }
        if (lRoot == null || rRoot == null || lRoot.val != rRoot.val) {
            return false;
        }
        return recursion(lRoot.left,rRoot.right) && recursion(lRoot.right,rRoot.left);
    }
    boolean isSymmetrical(TreeNode pRoot) {
        if (pRoot == null) {
            return true;
        }
        return recursion(pRoot.left,pRoot.right);
    }
}
